package cn.edu.scau.cmi.xianjiehua.singleton;

import java.util.HashSet;
import java.util.Set;

public class Marshal {

	private String name;
	private static Set<Marshal> marshalSet = new HashSet<>();
	
	private Marshal(String name){
		this.name = name;
	}
	
	public static Set<Marshal> addInstance(String name){
		if(marshalSet.size()<10){
			marshalSet.add(new Marshal(name));
		}else {
			System.out.println("对不起，民国只有十大元帅，"+name+"不是元帅！");
		}
		return marshalSet;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	
}